package org.ssp.servlet;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.ssp.util.SmsUtil;


/**
 * 发送短信
 * 
 * @author susp
 *
 */
@WebServlet("/sms")
public class SendSmsServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       

	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		 String phonenumber=request.getParameter("phonenumber");
		 String testUsername = "Goodsu"; //在短信宝注册的用户名
         String testPassword = "ssp08294112"; //在短信宝注册的密码
         String testPhone = phonenumber;
         // 注意测试时，也请带上公司简称或网站签名，发送正规内容短信。千万不要发送无意义的内容：例如 测一下、您好。否则可能会收不到
         String testContent = "【廣州歐星留學】您的验证码是1234,５分钟内有效。若非本人操作请忽略此消息。";
         String httpUrl = "http://api.smsbao.com/sms";
         SmsUtil.sendMessage(httpUrl, testUsername,testPassword,testPhone,testContent);
         request.getRequestDispatcher("/login.jsp").forward(request, response);
	}

	
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(request, response);
	}

}
